#include "wx/wxprec.h"
#if wxUSE_XRC && wxUSE_TOGGLEBTN

#include "wx/xrc/xh_tglbtn.h"
#include "wx/tglbtn.h"
#include "wx/button.h" // solely for wxBU_EXACTFIT

IMPLEMENT_DYNAMIC_CLASS( wxToggleButtonXmlHandler, wxXmlResourceHandler )

wxToggleButtonXmlHandler::wxToggleButtonXmlHandler()
  : wxXmlResourceHandler() {
  XRC_ADD_STYLE( wxBU_EXACTFIT );
  AddWindowStyles();
}

wxObject *wxToggleButtonXmlHandler::DoCreateResource() {
  XRC_MAKE_INSTANCE( control, wxToggleButton )
  control->Create( m_parentAsWindow,
                   GetID(),
                   GetText( wxT( "label" ) ),
                   GetPosition(), GetSize(),
                   GetStyle(),
                   wxDefaultValidator,
                   GetName() );
  control->SetValue( GetBool( wxT( "checked" ) ) );
  SetupWindow( control );
  return control;
}

bool wxToggleButtonXmlHandler::CanHandle( wxXmlNode *node ) {
  return IsOfClass( node, wxT( "wxToggleButton" ) );
}

#endif // wxUSE_XRC && wxUSE_TOGGLEBTN
